﻿using System;
using System.ComponentModel;

namespace Esponce.QRCode.Models
{
	public class TimeRecord : IRecord, INotifyPropertyChanged
	{
		#region Public properties
		public DateTime? Time
		{
			get
			{
				return this.time;
			}
			set
			{
				if (this.time != value)
				{
					this.time = value;
					OnPropertyChanged("Time");
					OnPropertyChanged("Name");
				}
			}
		}
		private DateTime? time;

		public int Count
		{
			get
			{
				return this.count;
			}
			set
			{
				if (this.count != value)
				{
					this.count = value;
					OnPropertyChanged("Count");
				}
			}
		}
		private int count;

		public string Name
		{
			get
			{
				return this.Time != null ? this.Time.Value.ToString("yyyy-MM-dd") : null;
			}
			set
			{
				//Not handled here
			}
		}
		#endregion

		#region INotifyPropertyChanged Members
		public event PropertyChangedEventHandler PropertyChanged;
		protected virtual void OnPropertyChanged(string propertyName)
		{
			if (PropertyChanged != null)
			{
				PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
			}
		}
		#endregion
	}
}
